﻿@model S4Store.Models.Inventory.IndexModel
@{
    Layout = null;
    ViewBag.Title = "Index";
    S4Store.Models.Chart.Column ChartModel = new S4Store.Models.Chart.Column();
    //ChartModel.Name = "登记客户";
    ChartModel.YAxis = "车型库存动态汇总";
    //ChartModel.Width = 500;
    ChartModel.Height = 300;
    Model.Reports.ForEach(t => ChartModel.XAxis.Add(t.CarBrand.Name));

    S4Store.Models.Chart.ChartSeries series1 = new S4Store.Models.Chart.ChartSeries();
    series1.Name = "标准库存度";
    Model.Reports.ForEach(t => series1.Data.Add(t.CarKpiMonthConfig.InventoryIndexTarget));
    ChartModel.Serieses.Add(series1);


    S4Store.Models.Chart.ChartSeries series2 = new S4Store.Models.Chart.ChartSeries();
    series2.Name = "实际库存度";
    Model.Reports.ForEach(t => series2.Data.Add(t.InventoryCoefficient));
    ChartModel.Serieses.Add(series2);
    ChartModel.IsRate = false;
    ChartModel.Colors = new List<string> { S4Store.Models.Chart.Color.Green ,S4Store.Models.Chart.Color.Blue};
}
<script type="text/javascript">
    $(function () {
        var $c = $("#myContentArea");
        var count = $("#myContentArea").find("table td").has(".value").size();
        var right = parseInt($("#right").css("width").replace("px", "")) - 20;
        if (count * 190 + 70 >= right) {
            $c.width(count * 190 + 70);
        }
    });
</script>
<div style="height: 100%; width: 100%; overflow: auto;">
<div id="myContentArea" style="overflow:hidden">
@Html.Action("ReportBar", "Common", Model.BarModel)
<div style="margin:20px; text-align:center; font-size:14px; color:@S4Store.Models.Chart.Color.Red">库存总数：@Model.Total &nbsp;&nbsp; 总库存系数：@Model.TotalXs.toInt()</div>
@Html.Partial("../Chart/Column", ChartModel)
<div style=" margin-left:70px">
        <table style="width:100%">
            <tr>
            @for (int i = 0; i < Model.Reports.Count; i++)
            {
                var m = Model.Reports[i];
                var diff = m.InventoryCoefficientDiff;
                <td align="center">
                    @if (diff >= 0)
                    {
                        <a class="specialGreen"  href="@Url.Action("CarBrandInventory", new { Month = Model.BarModel.Month.ToString("yyyy-MM-dd"), SearchCarBrandId = m.CarBrand.Id })" target="navtab" tip="@(m.CarBrand.Name)库存动态" title="上月库存系数与本月库存系数的差值">
                            <div class="value">@diff.toInt()</div>
                            <div class="rt">库存数：@m.Inventory</div>
                            <div class="rb"></div>
                        </a>
                    }
                    else
                    {
                        <a class="specialRed"  href="@Url.Action("CarBrandInventory", new { Month = Model.BarModel.Month.ToString("yyyy-MM-dd"), SearchCarBrandId =m.CarBrand.Id })" target="navtab" tip="@(m.CarBrand.Name)库存动态" title="上月库存系数与本月库存系数的差值">
                            <div class="value">@diff.toInt()</div>
                            <div class="rt">库存数：@m.Inventory</div>
                            <div class="rb"></div>
                        </a>
                    }
                </td>
            }
            </tr>
        </table>
        </div>
</div>
</div>
